<?php
namespace app\index\controller;

use service\DataService;
use think\Db;
use think\Controller;
/**
 * @desc 司机信息
 * Class Valet
 * @package app\index\controller
 */
class Member extends Controller
{
    public $table = 'Members';

    public function register(){

        return view();
    }

    public function registerDo(){
        $datas = $this->request->post();

        $datas['created_at'] = date('Y-m-d H:i:s');

        $salt = createRandom();
        $datas['salt'] = $salt;
        $datas['rank'] = 2;
        $datas['password'] = md5($salt.$datas['password']);
        $company_id = DataService::save(Db::name($this->table), $datas, 'id', []);
        if($company_id){
            $data = [
                'code' => 200,
                'msg'   => '注册成功了！',
            ];
        }else{
            $data = [
                'code' => 0,
                'msg'   => '注册失败',
            ];
        }

        return json($data);

    }

    public function uploads(){
        return uploads();
    }

}
